<?php

	if (!defined('EXPONENT')) exit('');
	if (exponent_permissions_check(array('administrate','configure','create'),$loc)) 
	{   
		$survey=0;
		if (isset($_REQUEST['id']))
		{
			
			$survey=intval($_REQUEST['id']);
			$survey=$db->selectObject('surveymodule_companies',"id=".$survey);
			if (isset($survey->id))
				$loc = unserialize($survey->location_data);
			else
				$survey = surveymodule_cat::survey_getDefaultObject();
		}
		else
			$survey = surveymodule_cat::survey_getDefaultObject();
		
		$template = new template('surveymodule','_survey_edit', $loc);
		
		// prepare before load template
		$cat_dropdown=$db->selectDropdown("surveymodule_catergory","name","location_data = '".serialize($loc)."'");
		$template->assign("cat_dropdown_array",$cat_dropdown);
		
		// active
		$is_active_dropdown = array(0=>"In-active", 1=>"Active");
		$template->assign("isactive_dropdown",$is_active_dropdown);
		
		// time_start, time_end
		$survey->time_start = date("n/j/Y H:i:s",$survey->time_start);
		$survey->time_end = date("n/j/Y H:i:s",$survey->time_end);
		
		$template->assign("is_edit",(isset($survey->id))?1:0);
		$template->assign("survey",$survey);
		$template->output();
	}
	else 
	{
		echo SITE_404_HTML;
	}
?>